Skip to main content
Updated for 2014
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to perform a Performing join on simultaneous spatial and attribute criteria in ArcGIS for Desktop?

added 21 characters in body
Source Link
hoge6b01
  • 1.1k
  • 4
  • 20
  • 40

I have two point layers and want to perform a spatial join on nearest distance.

Normally it is easy with ArcMap. But now I have a restricting condition on the spatial join. The restriction only allows the attributes to be joined if the nearest point is within the same country.

Both point layers have information about the country in their attribute table (e.g., "de" for Germany). So it must be some spatial join like:

Join attribute B to layer A on nearest distance where countryID_Layer A = countryID_Layer B.

Does anybody have an idea how I could solve this?

EDIT: Image I have following attributes: Table1(hotels): h_key, l_iso_a2, geom and in Table2(iata_codes): loc, ctry, geom

EDIT2: I tried to write the SQL-Statement, but it does not work somehow. Can anybody help me with this statement?:

select distinct on (h.h_key) h.h_key, h.l_iso_a2, i.loc, i.ctry, distance
from ( select h.h_key, h.l_iso_a2, i.loc, i.ctry as country2, st_distance (h.geom,
i.geom) as distance 
from hotels AS h, iata_codes AS i 
where h.l_iso_a2 = i.ctry order by h.geom <-> i.geom ) as iata_codes_h_key;

I have two point layers and want to perform a spatial join on nearest distance.

Normally it is easy with ArcMap. But now I have a restricting condition on the spatial join. The restriction only allows the attributes to be joined if the nearest point is within the same country.

Both point layers have information about the country in their attribute table (e.g., "de" for Germany). So it must be some spatial join like:

Join attribute B to layer A on nearest distance where countryID_Layer A = countryID_Layer B.

Does anybody have an idea how I could solve this?

EDIT: Image I have following attributes: Table1: h_key, l_iso_a2, geom and in Table2 loc, ctry, geom

EDIT2: I tried to write the SQL-Statement, but it does not work somehow. Can anybody help me with this statement?:

select distinct on (h.h_key) h.h_key, h.l_iso_a2, i.loc, i.ctry, distance
from ( select h.h_key, h.l_iso_a2, i.loc, i.ctry as country2, st_distance (h.geom,
i.geom) as distance 
from hotels AS h, iata_codes AS i 
where h.l_iso_a2 = i.ctry order by h.geom <-> i.geom ) as iata_codes_h_key;

I have two point layers and want to perform a spatial join on nearest distance.

Normally it is easy with ArcMap. But now I have a restricting condition on the spatial join. The restriction only allows the attributes to be joined if the nearest point is within the same country.

Both point layers have information about the country in their attribute table (e.g., "de" for Germany). So it must be some spatial join like:

Join attribute B to layer A on nearest distance where countryID_Layer A = countryID_Layer B.

Does anybody have an idea how I could solve this?

EDIT: Image I have following attributes: Table1(hotels): h_key, l_iso_a2, geom and in Table2(iata_codes): loc, ctry, geom

EDIT2: I tried to write the SQL-Statement, but it does not work somehow. Can anybody help me with this statement?:

select distinct on (h.h_key) h.h_key, h.l_iso_a2, i.loc, i.ctry, distance
from ( select h.h_key, h.l_iso_a2, i.loc, i.ctry as country2, st_distance (h.geom,
i.geom) as distance 
from hotels AS h, iata_codes AS i 
where h.l_iso_a2 = i.ctry order by h.geom <-> i.geom ) as iata_codes_h_key;
added 404 characters in body
Source Link
hoge6b01
  • 1.1k
  • 4
  • 20
  • 40

I have two point layers and want to perform a spatial join on nearest distance.

Normally it is easy with ArcMap. But now I have a restricting condition on the spatial join. The restriction only allows the attributes to be joined if the nearest point is within the same country.

Both point layers have information about the country in their attribute table (e.g., "de" for Germany). So it must be some spatial join like:

Join attribute B to layer A on nearest distance where countryID_Layer A = countryID_Layer B.

Does anybody have an idea how I could solve this?

EDIT: Image I have following attributes: Table1: H_KEYh_key, country_idl_iso_a2, geom and in Table2 IATA_keyloc, country_idctry, the_geomgeom

EDIT2: I tried to write the SQL-Statement, but it does not work somehow. Can anybody help me with this statement?:

select distinct on (h.h_key) h.h_key, h.l_iso_a2, i.loc, i.ctry, distance
from ( select h.h_key, h.l_iso_a2, i.loc, i.ctry as country2, st_distance (h.geom,
i.geom) as distance 
from hotels AS h, iata_codes AS i 
where h.l_iso_a2 = i.ctry order by h.geom <-> i.geom ) as iata_codes_h_key;

I have two point layers and want to perform a spatial join on nearest distance.

Normally it is easy with ArcMap. But now I have a restricting condition on the spatial join. The restriction only allows the attributes to be joined if the nearest point is within the same country.

Both point layers have information about the country in their attribute table (e.g., "de" for Germany). So it must be some spatial join like:

Join attribute B to layer A on nearest distance where countryID_Layer A = countryID_Layer B.

Does anybody have an idea how I could solve this?

EDIT: Image I have following attributes: Table1: H_KEY, country_id, geom and in Table2 IATA_key, country_id, the_geom

I have two point layers and want to perform a spatial join on nearest distance.

Normally it is easy with ArcMap. But now I have a restricting condition on the spatial join. The restriction only allows the attributes to be joined if the nearest point is within the same country.

Both point layers have information about the country in their attribute table (e.g., "de" for Germany). So it must be some spatial join like:

Join attribute B to layer A on nearest distance where countryID_Layer A = countryID_Layer B.

Does anybody have an idea how I could solve this?

EDIT: Image I have following attributes: Table1: h_key, l_iso_a2, geom and in Table2 loc, ctry, geom

EDIT2: I tried to write the SQL-Statement, but it does not work somehow. Can anybody help me with this statement?:

select distinct on (h.h_key) h.h_key, h.l_iso_a2, i.loc, i.ctry, distance
from ( select h.h_key, h.l_iso_a2, i.loc, i.ctry as country2, st_distance (h.geom,
i.geom) as distance 
from hotels AS h, iata_codes AS i 
where h.l_iso_a2 = i.ctry order by h.geom <-> i.geom ) as iata_codes_h_key;
added 121 characters in body
Source Link
hoge6b01
  • 1.1k
  • 4
  • 20
  • 40
Loading
improved formatting
Source Link
whuber
  • 70.2k
  • 16
  • 187
  • 282
Loading
Source Link
hoge6b01
  • 1.1k
  • 4
  • 20
  • 40
Loading