def loadGeoJSON(filename): """Load GeoJSON files.""" if filename.endswith('.gz'): filename = gunzip(filename) jr = vtk.vtkGeoJSONReader() jr.SetFileName(filename) jr.Update() return Actor(jr.GetOutput())
def load_geojson(input_string, feature_properties={}): '''Parses input_string with vtkGeoJSONReader, returns vtkPolyData feature_properties is a dictionary of name-default_values to attach as cell data in the returned vtkPolyData. ''' reader = vtk.vtkGeoJSONReader() reader.StringInputModeOn() reader.SetStringInput(input_string) for name,default_value in feature_properties.items(): reader.AddFeatureProperty(name, default_value) reader.Update() return reader.GetOutput()
def load_geojson(input_string, feature_properties={}): '''Parses input_string with vtkGeoJSONReader, returns vtkPolyData feature_properties is a dictionary of name-default_values to attach as cell data in the returned vtkPolyData. ''' reader = vtk.vtkGeoJSONReader() reader.StringInputModeOn() reader.SetStringInput(input_string) for name,default_value in feature_properties.items(): reader.AddFeatureProperty(name, default_value) reader.Update() return reader.GetOutput()
def loadGeoJSONData(filename): geoString = None with open(filename, 'r') as f: geoString = f.read() reader = vtk.vtkGeoJSONReader() reader.StringInputModeOn() reader.SetStringInput(geoString) reader.Update() dataset = reader.GetOutput() return dataset