Created
November 19, 2021 14:01
-
-
Save marcellobenigno/adeec0d48b8876483044aa0bd86c8995 to your computer and use it in GitHub Desktop.
Exemplos PyQGIS
This file contains hidden or 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
| diretorio = '/Users/marcellodebarrosfilho/Downloads/Limite_do_Estado_PB_IBGE_2015/' | |
| arquivo = 'Limite_Estadual_IBGE2015_SIRGAS2000_System.shp' | |
| caminho_completo = diretorio + arquivo | |
| limite_estadual = iface.addVectorLayer(caminho_completo, 'Limite PB', 'ogr') | |
| limite_estadual.setName('Limite PB') | |
| diretorio = '/Users/marcellodebarrosfilho/Downloads/' | |
| geopackage = 'dados_pb.gpkg' | |
| camada = 'drenagem' | |
| caminho_completo = diretorio + geopackage + '|layername=' + camada | |
| drenagem = iface.addVectorLayer(caminho_completo, '', 'ogr') | |
| drenagem.setName('Drenagem') |
This file contains hidden or 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
| diretorio = '/Users/marcellodebarrosfilho/Downloads/Limite_do_Estado_PB_IBGE_2015/' | |
| arquivo = 'Limite_Estadual_IBGE2015_SIRGAS2000_System.shp' | |
| caminho_completo = diretorio + arquivo | |
| limite = QgsVectorLayer(caminho_completo, 'limite', 'ogr') | |
| QgsProject.instance().addMapLayer(limite) |
This file contains hidden or 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
| diretorio = '/Users/marcellodebarrosfilho/Downloads/Limite_do_Estado_PB_IBGE_2015/' | |
| arquivo = 'denali_hillshade.tif' | |
| caminho_completo = diretorio + arquivo | |
| denali = iface.addRasterLayer(caminho_completo,'denali', 'gdal') |
This file contains hidden or 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
| diretorio = '/Users/marcellodebarrosfilho/Downloads/Limite_do_Estado_PB_IBGE_2015/' | |
| arquivo = 'denali_hillshade.tif' | |
| caminho_completo = diretorio + arquivo | |
| denali_hillshade = QgsRasterLayer(caminho_completo, 'denali', 'gdal') | |
| QgsProject.instance().addMapLayer(denali_hillshade) |
This file contains hidden or 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
| uri = "url=http://a.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png&zmax=19&zmin=0&type=xyz" | |
| tile_layer = QgsRasterLayer(uri,'OSM','wms') | |
| QgsProject.instance().addMapLayer(tile_layer) | |
| diretorio = '/Users/marcellodebarrosfilho/Downloads/Limite_do_Estado_PB_IBGE_2015/' | |
| arquivo = 'pocos_pb_ok.csv' | |
| uri = f"file:{diretorio}{arquivo}?type=csv&delimiter={','}&detectTypes=yes&xField={'lng'}&yField={'lat'}&crs=EPSG:{4326}" | |
| pocos = QgsVectorLayer(uri, 'pocos', 'delimitedtext') | |
| QgsProject.instance().addMapLayer(pocos) | |
| pocos_extent = pocos.extent() | |
| iface.mapCanvas().setExtent(pocos_extent) | |
| iface.mapCanvas().refresh() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment