From f626f6800b1dd22264677b26d76c72eab6c52415 Mon Sep 17 00:00:00 2001 From: jshermeyer Date: Wed, 29 Nov 2017 11:49:27 -0500 Subject: [PATCH 1/3] Removed osmnx instance --- spacenetutilities/geoTools.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/spacenetutilities/geoTools.py b/spacenetutilities/geoTools.py index d49e631..7c3cd9f 100644 --- a/spacenetutilities/geoTools.py +++ b/spacenetutilities/geoTools.py @@ -1020,29 +1020,28 @@ def explodeGeoPandasFrame(inGDF): def createBufferGeoPandas(inGDF, bufferDistanceMeters=5, bufferRoundness=1, projectToUTM=True): # Calculate CenterLine ## Define Buffer Constraints - - + + # Transform gdf Roadlines into UTM so that Buffer makes sense if projectToUTM: - tmpGDF = osmnx.project_gdf(inGDF) + if inGDF.crs: + tmpGDF = projectGDFToUTM(inGDF, srcCrs=inGDF.crs) + else: + tmpGDF = projectGDFToUTM(inGDF, srcCrs="+proj=longlat +datum=WGS84 +no_defs") else: tmpGDF = inGDF gdf_utm_buffer = tmpGDF - # perform Buffer to produce polygons from Line Segments - gdf_utm_buffer['geometry'] = tmpGDF.buffer(bufferDistanceMeters, - bufferRoundness) - - gdf_utm_dissolve = gdf_utm_buffer.dissolve(by='class') + gdf_utm_buffer['geometry'] = tmpGDF.buffer(bufferDistanceMeters,bufferRoundness) + gdf_utm_dissolve = gdf_utm_buffer.dissolve(by='road_type') gdf_utm_dissolve.crs = gdf_utm_buffer.crs - + if projectToUTM: gdf_buffer = gdf_utm_dissolve.to_crs(inGDF.crs) else: gdf_buffer = gdf_utm_dissolve - return gdf_buffer From 456c83cd798669e7f588db2cc9c3921852aea5c8 Mon Sep 17 00:00:00 2001 From: jshermeyer Date: Wed, 29 Nov 2017 12:17:48 -0500 Subject: [PATCH 2/3] Update README.md --- README.md | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 98601c1..96d1346 100644 --- a/README.md +++ b/README.md @@ -11,38 +11,25 @@ Further download instructions for the [SpaceNet Dataset](https://github.com/Spac ## Installation Instructions -Several packages require binaries to be installed before pip installing the other packages. Conda is a simple way to install everything and their dependencies +Several packages require binaries to be installed before pip installing spacenetutilities. Conda is a simple way to install everything and their dependencies and creating a dedicated conda environment is recommended. Python 3.5 is recommended as some packages run into issues in Python 2.7 and 3.6. If using another version proceed at your own risk! -* Install GDAL binaries and scripts +* Create a conda environment for python 3.5 and then enter it ```commandline -conda install -c conda-forge gdal +conda create -n spacenet_py35 python=3.5 anaconda +source activate spacenet_py35 #source deactivate to exit! ``` -* Install [Rtree](http://toblerity.org/rtree/install.html) +* Install these packages via conda ```commandline -conda install -c conda-forge rtree +conda install -c conda-forge cython libgdal gdal numpy opencv pip pyproj matplotlib networkx=1.11 fiona scikit-image scikit-learn scipy geopandas tqdm shapely=1.5.16 rasterio affine pillow ``` -* Install [pyproj](https://pypi.python.org/pypi/pyproj) +* Install these packages via pip ```commandline -conda install -c conda-forge pyproj -``` -* Install [geopandas](https://pypi.python.org/pypi/geopandas) -```commandline -conda install -c conda-forge geopandas -``` - -* Install [shapely](https://pypi.python.org/pypi/shapely) -```commandline -conda install -c conda-forge shapely +pip install utm +pip install osmnx==0.5 ``` -* Install [rasterio](https://pypi.python.org/pypi/rasterio) -```commandline -conda install -c conda-forge rasterio -``` - - -* Pip Install from github +* Pip install spacenetutilities from github ```commandline git clone -b spacenetV3 https://github.com/SpaceNetChallenge/utilities.git cd utilities @@ -55,7 +42,7 @@ or pip install --upgrade git+https://github.com/SpaceNetChallenge/utilities.git ``` - +If something breaks try checking your ~/.bash_profile or equivalent to ensure you are not pointing at other instances of gdal, etc... ## Evaluation Metric From 11fe854bafd7caaad88c6641509a94db9883d5a2 Mon Sep 17 00:00:00 2001 From: jshermeyer Date: Thu, 30 Nov 2017 08:09:04 -0500 Subject: [PATCH 3/3] Added lane multiplier --- spacenetutilities/geoTools.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/spacenetutilities/geoTools.py b/spacenetutilities/geoTools.py index 7c3cd9f..ae680f5 100644 --- a/spacenetutilities/geoTools.py +++ b/spacenetutilities/geoTools.py @@ -1017,11 +1017,9 @@ def explodeGeoPandasFrame(inGDF): # return outGDF -def createBufferGeoPandas(inGDF, bufferDistanceMeters=5, bufferRoundness=1, projectToUTM=True): +def createBufferGeoPandas(inGDF, bufferDistanceMeters=5, bufferRoundness=1, projectToUTM=True, multiply=False): # Calculate CenterLine ## Define Buffer Constraints - - # Transform gdf Roadlines into UTM so that Buffer makes sense if projectToUTM: if inGDF.crs: @@ -1033,9 +1031,19 @@ def createBufferGeoPandas(inGDF, bufferDistanceMeters=5, bufferRoundness=1, proj gdf_utm_buffer = tmpGDF # perform Buffer to produce polygons from Line Segments - gdf_utm_buffer['geometry'] = tmpGDF.buffer(bufferDistanceMeters,bufferRoundness) - gdf_utm_dissolve = gdf_utm_buffer.dissolve(by='road_type') - gdf_utm_dissolve.crs = gdf_utm_buffer.crs + #Buffer based on number of lanes + if multiply: + tmpGDF['buffval'] = pd.to_numeric(tmpGDF['lane_number'])*bufferDistanceMeters + gdf_utm_buffer['geometry']= tmpGDF.apply(lambda x: x.geometry.buffer(x.buffval,bufferRoundness), axis=1) + gdf_utm_dissolve = gdf_utm_buffer.dissolve(by='road_type') + gdf_utm_dissolve.crs = gdf_utm_buffer.crs + + #Do not buffer based on number of lanes + else: + gdf_utm_buffer['geometry'] = tmpGDF.buffer(bufferDistanceMeters,bufferRoundness) + gdf_utm_dissolve = gdf_utm_buffer.dissolve(by='road_type') + gdf_utm_dissolve.crs = gdf_utm_buffer.crs + if projectToUTM: gdf_buffer = gdf_utm_dissolve.to_crs(inGDF.crs) @@ -1047,3 +1055,5 @@ def createBufferGeoPandas(inGDF, bufferDistanceMeters=5, bufferRoundness=1, proj + +