Hot answers tagged

93

You are confusing two different operations dealing with Projections. Define a projection: You would use this when you have a shapefile or other feature class that does not currently have a spatial reference defined when you look at the properties in ArcGIS. You might also use this if you knew based on some observation, that the projection defined for the ...


47

In current versions of QGIS, you can use Copy Style and then Paste Style from the Layers top dropdown menu (if you have one or more layers selected in the layers list). For some older versions: You can select multiple layers in the layers list, right-click and use Paste Style from the context menu. For other older versions: The MultiQML plugin lets you ...


37

Right click on the mxd in ArcCatalog, click on Set data sources, and bulk change from there. However, this tool warns: Note: this dialog is intended primarily for preparing map documents for publication. Customizations (VBA code, UI Controls and custom toolbars), graphs, and table window appearance properties are removed from .mxd files when you update ...


32

Vector data can have properties stored at two levels. File level or Layer level. For feature class (a type of vector data), file level information is stored in a geodatabase. This consists of properties like feature class geometry, attribute table, assigned subtypes and domains, a coordinate system, etc:. All these file level properties make up the actual ...


31

Yes, it is possible. Before you can add a feature class you need to turn it into a feature layer. This arcpy code should help: import arcpy FC = r"C:\...\featureclass" arcpy.MakeFeatureLayer_management(FC, "nameoffeatureclass") MXD = arcpy.mapping.MapDocument(r"C:\...\your.mxd") DF = arcpy.mapping.ListDataFrames(MXD)[0] layer = arcpy.mapping.Layer("...


30

Although you have set the projection of your 3 other layers by the properties menu in ArcCatalog, you have failed to re-project the data to the proper coordinate system. Please try the Project tool, located in Data Management Tools → Projections and Transformations → Feature. This should allow you to create a new feature class that is projected ...


24

Try... # substitute 'self' with 'qgis.utils.iface' when run from Python console # 'self.iface = iface' would usually precede this command in your class layers = self.iface.legendInterface().layers() for layer in layers: layerType = layer.type() if layerType == QgsMapLayer.VectorLayer: # do some stuff here Culled from consolidatethread.py ...


22

My thoughts are: Export your shapefile to a file geodatabase feature class - I think its drawing performance will be better but am not sure by how much If you are using ArcGIS Desktop 10.0 or later move it into a Basemap Layer - this will improve drawing performance dramatically If you like the sound of pyramids for vector data, be sure to vote for this ...


22

Spatial joins are available in the field calculator after installing the refFunctions plugin. geomwithin(targetLayer,targetField)


20

The hint provided by @mdsummer of using byid=TRUE works accurately. See the reproducible example, below: library(rgeos) library(sp) #Create SpatialPlygons objects polygon1 <- readWKT("POLYGON((-190 -50, -200 -10, -110 20, -190 -50))") #polygon 1 polygon2 <- readWKT("POLYGON((-180 -20, -140 55, 10 0, -140 -60, -180 -20))") #polygon 2 par(mfrow = c(1,...


19

There are also two other ways: layers = self.iface.mapCanvas().layers() will give you a list of layers or layers = QgsMapLayerRegistry.instance().mapLayers() for name, layer in layers.iteritems(): print name, layer.type()


19

Assuming you use an ol.layer.Vector with an ol.source.GeoJSON you can use something like this: var vectorSource = new ol.source.GeoJSON({ projection : 'EPSG:3857', url: 'http://examples.org/fearures.json' }); var vectorLayer = new ol.layer.Vector({ source: vectorSource }); map.addLayer(vectorLayer); // show loading icon // ... var listenerKey = ...


19

Out of the box, field calculator does not support spatial joins across feature layers. But, if you have a look at NathanW's post on the function editor for qgis expressions you will be able to make out that we can script our own data interaction. The following script will allow you to express what you're after. It works by iterating through all features ...


18

I notice you have already found a solution that works for you, but I thought I might add some additional options that you or others may find useful. In GeoServer there is a capability known as Virtual OWS Services. The WMS, WFS, and WCS services are collectively known as the OWS services. When you make a request to one of these services you are making a ...


18

The layer extents are available in the Layer Properties | Metadata section.


17

This is because arcpy.Rename_management does not work on a map layer object - it works on objects on the disk. Instead try: layer.name = newName layer.name is a read/write attribute of the arcpy.mapping.Layer class.


17

Do you want to actually delete the layer from the geodatabase or remove it from the mxd? If you just want to remove the layer from your mxd, replace arcpy.Delete_management("CADAnnotation") with arcpy.mapping.RemoveLayer(df, lyr) If you want to delete the data source you can do this. for item in mxds: print (item) mxd = arcpy.mapping.MapDocument(...


17

For python console: QgsProject.instance().readPath("./") # also try "../" Or with dir(QgsProject.instance()) you find something like fileName() For python plugin (not tested!): from PyQt4.QtGui import QMessageBox from qgis.core import QgsProject path_absolute = QgsProject.instance().readPath("./") QMessageBox.information(None, "Title", "AP: " + ...


16

If you are using ArcGIS 10 and are interested in using Python, check out the help on Updating and fixing data sources with arcpy.mapping and the methods of the Layer object. Example: import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\Project_SDE1.mxd") mxd.findAndReplaceWorkspacePaths(r"Database Connections\Connection to GISSDE1.sde", ...


16

If anyone gets stuck with identifying a layer's type in OpenLayers 3, there is a more sophisticated JavaScript method to achieve this. As layer objects are created with layer constructors, the native instanceof JavaScript function can be used to check for layer type. As the identification of a layer type usually gets into an if or switch clause, one could ...


15

For ArcGIS 10.0, if you can make use of a read-only approach, the following code sample reveals the field (and joined table) that forms the basis for the symbology of a layer. It exports a temporary msd(a zip containing xml files) and loads the specific attributes into an object. These classes might be extended to gain access to additional layer attributes....


14

To access a vector file path, on a active layer, this code works well in Python Console: >>>import os >>>myfilepath= iface.activeLayer().dataProvider().dataSourceUri() >>>myfilepath u'/home/zeito/tiznados_canoa.tif' >>>(myDirectory,nameFile) = os.path.split(myfilepath) >>>myDirectory u'/home/zeito' >>>...


14

According to the docs here, you can pass the position in as an option when creating the layer control. Available positions are outlined here overlayPane = { "Endpoints" : endpointMarkerLayer, "Links" : linkLineLayer, }; // Add a layer control element to the map layerControl = L.control.layers(null, overlayPane, {position: 'topleft'}); layerControl....


14

In ol3 version 3.10.0 things have changed. So is more clear than older versions but still more complicated than ol2. So for TILE (ol.layer.Tile) layers your code snip should look like: //declare the layer var osmLayer = new ol.layer.Tile({ source: new ol.source.OSM() }); //asign the listeners on the source of tile layer osmLayer.getSource().on('...


14

With a little help from Python, we could set the border width for all layers in your "State" group to a specific value (e.g. 0.16 as shown in your image). Try testing the following in the Python Console: root = QgsProject.instance().layerTreeRoot() state_group = root.findGroup("State") border_width = 0.16 for layers in state_group.children(): layer = ...


14

Create Layer From Selected Features DOES NOT create a DYNAMIC layer. The resulting layer is not dynamic at all. It is based on an FIDset. If you change the source data, the FIDs will change and your selection layer will break. There is no where clause in a selection layer. It is based on FIDset (the FIDs that were selected when you used 'Create layer ...


13

This a simple tutorial one can follow to define or reproject (transform) a Coordinate Reference System (CRS) in ArcGIS 10.1+ starting from a CSV file. Open ArcMap; Click on File --> Add Data --> Add XY Data; Browse the CSV file which contains column A with longitude (or Easting) values; and column B with latitude (or Northing) values. Example: ...


13

These terms specifically relate to the ESRI software and data schemas. A feature class is a set of common geographic features, for example roads, or parcels, or land use, as they are stored in a geodatabase or shapefile, or other storage format. Here is the help file on Feature Class Basics. A feature layer is the representation of a feature class after ...


13

If I got you right, the answer is yes, QGIS supports dynamic layer names. You would need to write a Python macro to be ran every time the project is opened. This would be the workflow: Go to QGIS->Project->Project Properties and replace openProject() with the following Python code: def openProject(): import re, qgis iface = qgis.utils....


13

TL;DR To get all features of a layer by the layer name you do not need to activate it. Just use name = 'counties' layer = QgsProject.instance().mapLayersByName( name )[0] poles = layer.getFeatures() for pole in poles: if is_north(pole): print('it is the north pole') Active Layer First of all, you do not need to care about the active layer. ...


Only top voted, non community-wiki answers of a minimum length are eligible