Skip to content

Instantly share code, notes, and snippets.

@oscar9
Last active October 21, 2019 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscar9/296125be4e58e87d978c578ea3996000 to your computer and use it in GitHub Desktop.
Save oscar9/296125be4e58e87d978c578ea3996000 to your computer and use it in GitHub Desktop.
Set min and max scale for its visualization in a view #gvsig #scripting
# encoding: utf-8
import gvsig
from gvsig import geom
def main(*args):
# Creating new layer
ft = gvsig.createSchema()
ft.append("ID", "INTEGER")
ft.append("GEOMETRY", "GEOMETRY")
ft.get('GEOMETRY').setGeometryType(geom.POINT,geom.D2)
layer = gvsig.createShape(ft, prefixname="testScale")
store = layer.getFeatureStore()
layer.edit()
layer.append({"ID":1,"GEOMETRY":geom.createPoint(geom.D2, 10, 20)})
layer.append({"ID":2,"GEOMETRY":geom.createPoint(geom.D2, 20, 20)})
layer.append({"ID":3,"GEOMETRY":geom.createPoint(geom.D2, 20, 30)})
layer.commit()
gvsig.currentView().addLayer(layer)
#Change zoom
layer.setMinScale(1000)
layer.setMaxScale(5000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment