Created
December 31, 2015 17:16
-
-
Save micahcochran/42de8723a05d88e5659a to your computer and use it in GitHub Desktop.
geosshim.py Attempted Shapely support for Basemap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: This code does NOT work!!! | |
# Attempt at a shim for Shapely to work with basemap. | |
# This is to try to use Shapely for the code that need libgeos. | |
# The code is minimal on purpose. | |
# add this file into the lib/mpl_toolkits/basemap folder | |
# in __init__.py change this line: | |
# import _geoslib | |
# to: | |
# import geosshim as _geoslib | |
from shapely.geometry.base import BaseGeometry as ShapelyBaseGeometry | |
import shapely.geometry | |
import numpy | |
class BaseGeometry(ShapelyBaseGeometry): | |
# make shapely property a function | |
def is_valid(self): | |
return self.is_valid | |
def fix(self): | |
pass | |
# not working quite right for basemap | |
@property | |
def boundary(self): | |
return numpy.array(ShapelyBaseGeometry.boundary) | |
class Point(BaseGeometry, shapely.geometry.Point): | |
pass | |
class LineString(BaseGeometry, shapely.geometry.LineString): | |
pass | |
class Polygon(BaseGeometry, shapely.geometry.Polygon): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment