haotu : an open lab notebook


center gis point of a polygon shape file

Filed under: arcmap, R spatial — Tags: , — S @ 08:20


In the map document, open the attribute table for the polygon feature class by right-clicking the layer name.
In the attribute table, navigate to Table Options > Add Field and add two new fields of type Double. Name one ‘Longitude’ and the other ‘Latitude’.
Right-click the Longitude field and select Calculate Geometry.
In the Calculate Geometry dialog box, select ‘X Coordinate of Centroid’ from the Property drop-down menu. Click OK.
Right-click the Latitude field and select Calculate Geometry.
In the Calculate Geometry dialog box, select ‘Y Coordinate of Centroid’ from the Property drop-down menu. Click OK.


stack rasters with different extents etc..

Filed under: arcmap, R, R, R spatial, R Stats, Uncategorized — S @ 13:42


Join polygons like countries from mapdata

Filed under: arcmap, R, R, R spatial — S @ 13:28

DR<-map(database = 'worldHires',regions="Dominican Republic",fill=TRUE)
 DR<-map2SpatialPolygons(DR,IDs, proj4string=CRS("+proj=longlat +datum=WGS84"))
Haiti<-map(database = 'worldHires',regions="Haiti",fill=TRUE)
 Haiti<-map2SpatialPolygons(Haiti,IDs, proj4string=CRS("+proj=longlat +datum=WGS84"))
Hispaniola<-gUnion(DR, Haiti)

Note fill=TRUE


add unique id to attributes table ArcMap 10.3.1

Filed under: arcmap, Python — Tags: , , , — S @ 08:39

This requires a bit of Python scripting, but it is simple. See here for the original post

1. Add a numeric field (column) to attributes table (the column in blue is an example of what I want to produce):


2. Right click on the new field and select field calculator.


3. Make sure parser is Python and type is Numeric. In the code box put in:

counter = 100000
def uniqueID():
 global counter
 counter += 1
 return counter

and in the field = box make sure to give the function name


in this example.


4. Then it should produce a unique id for each element in the table. Note that you can change the starting number (1000000) and the increment number (1).




add XY lat long latitude longitude data in Arcmap 10.3

Filed under: arcmap, spatial — S @ 07:23

1. Click the + add data button and add the csv or other file with the XY data. It is helpful to have the columns labeled longitude and latitude.
2. Right click on the newly added table and display XY data.
3. There are some fields here that you can adjust if necessary, just make sure that longitude is X and latitude is Y
4. Once you click OK you will probably get a warning that says that the table you specified does not include an Object-ID field (even though it may very well).
5. Then right click on the newly made item in the table of contents, go to Data… and then Export Data…
6. You will probably want to change the name of the shape file by clicking the folder icon.
7. Then save it!

This is sort of helpful https://geonet.esri.com/thread/76217

You can also do this in the ArcCatalog



Create a free website or blog at WordPress.com.