Exemplo n.º 1
0
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())
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
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