haotu : an open lab notebook

2016/02/22

true copy of a data.table

Filed under: Manipulate Data in R, R — S @ 10:13
mycopy<-copy(DT)

2016/02/19

Join polygons like countries from mapdata

Filed under: arcmap, R, R, R spatial — S @ 13:28
library(maps)
library(mapdata)
library(maptools)
library(rgeos)

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

Note fill=TRUE

2016/02/03

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):

uniqueid1

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

uniqueid2

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

uniqueid()

in this example.

uniqueid3

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).

uniqueid4

 

Blog at WordPress.com.