{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Seeding from shapefile\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime\nimport geopandas as gpd\nfrom opendrift import test_data_folder\nfrom opendrift.models.oceandrift import OceanDrift\n\n\no = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seed particles within all polygons from shapefile\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.seed_from_shapefile(test_data_folder +\n 'shapefile_spawning_areas/Torsk.shp',\n number=1000, time=datetime.now())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternative by using GeoPandas and selecting a subset of two polygons\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "gdf = gpd.read_file(test_data_folder + 'shapefile_spawning_areas/Torsk.shp')\ngdf = gdf.iloc[[1, 5]]\no.seed_from_geopandas(gdf, number=2000, time=datetime.now())\n\no.plot(fast=True)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.14.3" } }, "nbformat": 4, "nbformat_minor": 0 }