Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
edifiles = recursive_glob(edi_dir)
print("Number of EDI files found = %s" % len(edifiles))
myobj = ShapeFilesCreator(edifiles, "c:/temp")
allper = myobj.all_unique_periods
gpd_phtensor = myobj.create_phase_tensor_shp(allper[iperiod], export_fig=False)[0]
gpd_retip = myobj.create_tipper_real_shp(allper[iperiod], export_fig=False)[0]
gpd_imtip = myobj.create_tipper_imag_shp(allper[iperiod], export_fig=False)[0]
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
# composing two layers in a map
f, ax = plt.subplots(1, figsize=(20, 12))
# ax.set_xlim([140.5,141])
# ax.set_ylim([-21,-20])
# Add layer of polygons on the axis
# world.plot(ax=ax, alpha=0.5) # background map
gpd_phtensor.plot(ax=ax, linewidth=2, facecolor='grey', edgecolor='black')
gpd_retip.plot(ax=ax, color='red', linewidth=4)
gpd_imtip.plot(ax=ax, color='blue', linewidth=4)
if outfile is not None:
plt.savefig(outfile) # ( 'C:/temp/phase_tensor_tippers.png')
confKeys = list(conf.keys())
prcsKeys = list(prcs.keys())
# parse top-level configuration key information
if 'name' in confKeys:
self.name = conf['name']
else:
raise AttributeError('provided yaml file does not have a name parameter in configuration')
if 'region' in confKeys:
self.region = gpd.read_file(conf['region'])
elif 'country' in confKeys:
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
country = world[world.name == conf['country']]
if len(country) >= 1:
self.region = country
else:
raise ValueError('could not parse selected country from world shapefile')
elif 'boundingbox' in confKeys:
from shapely import geometry
self.region = gpd.GeoDataFrame(pd.DataFrame({'id':[0],'geometry':[geometry.box(*conf['boundingbox'])]}))
else:
raise AttributeError('provided yaml file does not have a specified region in configuration')
if 'credentials' in confKeys:
self.credentials = conf['credentials']
else:
the `Geometric Manipulations ` example for more
details.
First we'll import a dataset containing each borough in New York City. We'll
use the ``datasets`` module to handle this quickly.
"""
import numpy as np
import matplotlib.pyplot as plt
from shapely.geometry import Point
from geopandas import GeoSeries, GeoDataFrame
import geopandas as gpd
np.random.seed(1)
DPI = 100
path_nybb = gpd.datasets.get_path('nybb')
boros = GeoDataFrame.from_file(path_nybb)
boros = boros.set_index('BoroCode')
boros
##############################################################################
# Next, we'll plot the raw data
ax = boros.plot()
plt.xticks(rotation=90)
plt.savefig('nyc.png', dpi=DPI, bbox_inches='tight')
##############################################################################
# We can easily retrieve the convex hull of each shape. This corresponds to
# the outer edge of the shapes.
boros.geometry.convex_hull.plot()
plt.xticks(rotation=90)
# ``GeoDataFrame``. (note that ``points_from_xy()`` is an enhanced wrapper for
# ``[Point(x, y) for x, y in zip(df.Longitude, df.Latitude)]``)
gdf = geopandas.GeoDataFrame(
df, geometry=geopandas.points_from_xy(df.Longitude, df.Latitude))
###############################################################################
# ``gdf`` looks like this :
print(gdf.head())
###############################################################################
# Finally, we plot the coordinates over a country-level map.
world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
# We restrict to South America.
ax = world[world.continent == 'South America'].plot(
color='white', edgecolor='black')
# We can now plot our ``GeoDataFrame``.
gdf.plot(ax=ax, color='red')
plt.show()
###############################################################################
# From WKT format
# ===============
# Here, we consider a ``DataFrame`` having coordinates in WKT format.
df = pd.DataFrame(
--------------------------------
This example shows how you can add a background basemap to plots created
with the geopandas ``.plot()`` method. This makes use of the
`contextily `__ package to retrieve
web map tiles from several sources (OpenStreetMap, Stamen).
"""
# sphinx_gallery_thumbnail_number = 3
import geopandas
###############################################################################
# Let's use the NYC borough boundary data that is available in geopandas
# datasets. Plotting this gives the following result:
df = geopandas.read_file(geopandas.datasets.get_path('nybb'))
ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
###############################################################################
# Convert the data to Web Mercator
# ================================
#
# Web map tiles are typically provided in
# `Web Mercator `__
# (`EPSG 3857 `__), so we need to make sure to convert
# our data first to the same CRS to combine our polygons and background tiles
# in the same map:
df = df.to_crs(epsg=3857)
###############################################################################