qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.63k stars 3.01k forks source link

Vector Tiles, add a tool to export the data #44951

Open bojanv55 opened 3 years ago

bojanv55 commented 3 years ago

Feature description

I imported Vector Tile layer, and I can see feature when I select it in the right pane, but I cannot export it. Is it possible at all to export currently visible features from the map, since I can see that QGIS can read those? As you can see place_label is visible and has all the needed data - but not how can I export it from the QGIS.

image

Additional context

No response

gioman commented 3 years ago

@bojanv55 is this a question or a feature request?

bojanv55 commented 3 years ago

@gioman I guess both. Since I'm no QGIS expert - maybe there is already some way to do feature export (eg from python console or smth)? Otherwise it would be feature req.

gioman commented 3 years ago

@gioman I guess both. Since I'm no QGIS expert - maybe there is already some way to do feature export (eg from python console or smth)? Otherwise it would be feature req.

@bojanv55 can you post/share your datasource?

bojanv55 commented 3 years ago

Just the standard mapbox vector tiles connection:

image

gioman commented 3 years ago

Just the standard mapbox vector tiles connection:

@bojanv55 can I try that without a key?

bojanv55 commented 3 years ago

It's free to register https://account.mapbox.com/

And then just export the link from https://studio.mapbox.com/

gioman commented 3 years ago

@bojanv55 not a vector tiles expert here, but I don't think you can just "save as" a vector tile layer as you would do with other datasources. I don't even know if this is technically possible, so don't know if this even is meaningful as feature request.

bojanv55 commented 3 years ago

@gioman It is possible, since I can go to one of the features and do CTRL+C. but it is not that easy to go feature by feature and do this, since I cannot select all at once. And I'm definitely sure that there is some easier way to select an export it from python console inside of QGIS.

gioman commented 3 years ago

@gioman It is possible, since I can go to one of the features and do CTRL+C. but it is not that easy to go feature by feature and do this, since I cannot select all at once. And I'm definitely sure that there is some easier way to select an export it from python console inside of QGIS.

@bojanv55 you can do that also with some WMS services, but you don't have access to the table of attributes and the geometries as you would in a normal vector.

bojanv55 commented 3 years ago

@gioman

tiles

pathmapper commented 3 years ago

@gioman is right, you can not

just "save as" a vector tile layer as you would do with other datasources

because the features come from tiled vector data, so you would have to deal with split or duplicated data, even for point features.

The following quote from https://docs.mapbox.com/mapbox-gl-js/api/map/#map#queryrenderedfeatures gives some examples:

Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. The results of the query will be those parts of the highway that lie within the map tiles covering the bounding rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple tiles due to tile buffering.

bojanv55 commented 3 years ago

@pathmapper that is correct. Just wanted to find a way to export all. Then I will handle duplicated data outside of QGIS.

Tried to access it something like this, but do not know where the features are stored at:

layer = qgis.utils.iface.activeLayer()
print(dir(layer))
<QgsVectorTileLayer: 'karta'>
['Actions', 'AllStyleCategories', 'AnnotationLayer', 'AttributeTable', 'CustomProperties', 'Diagrams', 'Elevation', 'Fields', 'FlagDontResolveLayers', 'FlagReadExtentFromXml', 'FlagTrustLayerMetadata', 'Forms', 'GeometryOptions', 'Identifiable', 'Labeling', 'LayerConfiguration', 'LayerFlag', 'LayerFlags', 'LayerType', 'Legend', 'MapTips', 'MeshLayer', 'Metadata', 'Notes', 'PluginLayer', 'PointCloudLayer', 'Private', 'PropertyType', 'RasterLayer', 'ReadFlag', 'ReadFlags', 'Relations', 'Removable', 'Rendering', 'Searchable', 'Style', 'StyleCategories', 'StyleCategory', 'Symbology', 'Symbology3D', 'Temporal', 'VectorLayer', 'VectorTileLayer', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'abstract', 'accept', 'appendError', 'attribution', 'attributionUrl', 'autoRefreshInterval', 'autoRefreshIntervalChanged', 'beforeResolveReferences', 'blendMode', 'blendModeChanged', 'blockSignals', 'childEvent', 'children', 'clone', 'configChanged', 'connectNotify', 'createMapRenderer', 'crs', 'crsChanged', 'customEvent', 'customProperties', 'customProperty', 'customPropertyChanged', 'customPropertyKeys', 'dataChanged', 'dataProvider', 'dataSourceChanged', 'dataUrl', 'dataUrlFormat', 'decodedSource', 'deleteLater', 'dependencies', 'dependenciesChanged', 'destroyed', 'disconnect', 'disconnectNotify', 'dumpObjectInfo', 'dumpObjectTree', 'dynamicPropertyNames', 'elevationProperties', 'emitStyleChanged', 'encodedSource', 'error', 'event', 'eventFilter', 'exportNamedMetadata', 'exportNamedStyle', 'exportSldStyle', 'extensionPropertyType', 'extent', 'findChild', 'findChildren', 'flags', 'flagsChanged', 'formatLayerName', 'generateId', 'hasAutoRefreshEnabled', 'hasDependencyCycle', 'hasScaleBasedVisibility', 'htmlMetadata', 'id', 'importNamedMetadata', 'importNamedStyle', 'inherits', 'installEventFilter', 'invalidateWgs84Extent', 'isEditable', 'isInScaleRange', 'isRefreshOnNotifyEnabled', 'isSignalConnected', 'isSpatial', 'isTemporary', 'isTileBorderRenderingEnabled', 'isValid', 'isValidChanged', 'isWidgetType', 'isWindowType', 'keywordList', 'killTimer', 'labeling', 'legend', 'legendChanged', 'legendUrl', 'legendUrlFormat', 'loadDefaultMetadata', 'loadDefaultStyle', 'loadNamedMetadata', 'loadNamedMetadataFromDatabase', 'loadNamedStyle', 'loadNamedStyleFromDatabase', 'loadSldStyle', 'maximumScale', 'metaObject', 'metadata', 'metadataChanged', 'metadataUri', 'metadataUrl', 'metadataUrlFormat', 'metadataUrlType', 'minimumScale', 'moveToThread', 'name', 'nameChanged', 'objectName', 'objectNameChanged', 'opacity', 'opacityChanged', 'originalXmlProperties', 'parent', 'project', 'property', 'providerType', 'publicSource', 'pyqtConfigure', 'readCommonStyle', 'readCustomProperties', 'readLayerXml', 'readOnly', 'readSld', 'readStyle', 'readStyleManager', 'readSymbology', 'readXml', 'recalculateExtents', 'receivers', 'refreshOnNotifyMessage', 'reload', 'removeCustomProperty', 'removeEventFilter', 'renderer', 'renderer3D', 'renderer3DChanged', 'rendererChanged', 'repaintRequested', 'request3DUpdate', 'resolveReferences', 'saveDefaultMetadata', 'saveDefaultStyle', 'saveNamedMetadata', 'saveNamedStyle', 'saveSldStyle', 'sender', 'senderSignalIndex', 'setAbstract', 'setAttribution', 'setAttributionUrl', 'setAutoRefreshEnabled', 'setAutoRefreshInterval', 'setBlendMode', 'setCrs', 'setCustomProperties', 'setCustomProperty', 'setDataSource', 'setDataUrl', 'setDataUrlFormat', 'setDependencies', 'setError', 'setExtent', 'setFlags', 'setKeywordList', 'setLabeling', 'setLayerOrder', 'setLegend', 'setLegendUrl', 'setLegendUrlFormat', 'setMaximumScale', 'setMetadata', 'setMetadataUrl', 'setMetadataUrlFormat', 'setMetadataUrlType', 'setMinimumScale', 'setName', 'setObjectName', 'setOpacity', 'setOriginalXmlProperties', 'setParent', 'setProperty', 'setProviderType', 'setRefreshOnNofifyMessage', 'setRefreshOnNotifyEnabled', 'setRenderer', 'setRenderer3D', 'setScaleBasedVisibility', 'setShortName', 'setSubLayerVisibility', 'setTileBorderRenderingEnabled', 'setTitle', 'setTransformContext', 'setValid', 'shortName', 'signalsBlocked', 'source', 'sourceMaxZoom', 'sourceMinZoom', 'sourcePath', 'sourceType', 'startTimer', 'staticMetaObject', 'statusChanged', 'styleChanged', 'styleLoaded', 'styleManager', 'styleURI', 'subLayers', 'temporalProperties', 'thread', 'timerEvent', 'timestamp', 'title', 'tr', 'transformContext', 'trigger3DUpdate', 'triggerRepaint', 'type', 'undoStack', 'undoStackStyles', 'wgs84Extent', 'willBeDeleted', 'writeCommonStyle', 'writeCustomProperties', 'writeLayerXml', 'writeStyle', 'writeStyleManager', 'writeSymbology', 'writeXml']
gioman commented 3 years ago

Tried to access it something like this, but do not know where the features are stored at:

@bojanv55 this should be asked in the developers mailing list.