.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/maps/plot_shapefile.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_maps_plot_shapefile.py: GIS TropOMI Processing ====================== Get TropOMI from RSIG and save as GeoJSON and shapefiles. .. GENERATED FROM PYTHON SOURCE LINES 7-52 .. image-sg:: /auto_examples/maps/images/sphx_glr_plot_shapefile_001.png :alt: plot shapefile :srcset: /auto_examples/maps/images/sphx_glr_plot_shapefile_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/pycno/__init__.py:538: UserWarning: Downloading: https://www.giss.nasa.gov/tools/panoply/overlays/MWDB_Coasts_NA_1.cnob to /home/runner/.pycno/MWDB_Coasts_NA_1.cnob warnings.warn('Downloading: ' + url + ' to ' + str(datapatho)) | .. code-block:: default import matplotlib.pyplot as plt import geopandas as gpd from shapely import polygons import pyrsig import pycno coordkeys = [ 'Longitude_SW(deg)', 'Latitude_SW(deg)', 'Longitude_SE(deg)', 'Latitude_SE(deg)', 'Longitude_NE(deg)', 'Latitude_NE(deg)', 'Longitude_NW(deg)', 'Latitude_NW(deg)', 'Longitude_SW(deg)', 'Latitude_SW(deg)', ] cno = pycno.cno() # Retrieve data from RSIG (or cache) datakey = "tropomi.offl.no2.nitrogendioxide_tropospheric_column" bdate = "2023-07-23" bbox = (-75, 40, -69, 46) api = pyrsig.RsigApi(bbox=bbox) # Either ascii or xdr backend works, xdr is faster tropdf = api.to_dataframe(datakey, bdate=bdate, backend='xdr') geom = polygons(tropdf[coordkeys].values.reshape(-1, 5, 2)) gtropdf = gpd.GeoDataFrame( tropdf.drop(columns=coordkeys), geometry=geom, crs=4326 ) # Make Plot col = 'nitrogendioxide_tropospheric_column(molecules/cm2)' fig, ax = plt.subplots(figsize=(4, 4), dpi=300) gtropdf.plot(col, edgecolor="face", linewidth=0.1, legend=True, ax=ax) cno.drawstates(ax=ax, resnum=1) fig.savefig(f'{datakey}_{bdate}.png') # Save as a GIS Format gtropdf.to_file(f'{datakey}_{bdate}.geojson') # Shapefiles prefer short names gtropdf.rename(columns={ 'Timestamp(UTC)': 'time_utc', 'LATITUDE(deg)': 'lat_center', 'LONGITUDE(deg)': 'lon_center', col: 'no2_trop', }).to_file(f'{datakey}_{bdate}.shp') .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 5.517 seconds) .. _sphx_glr_download_auto_examples_maps_plot_shapefile.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_shapefile.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_shapefile.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_