Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link Ingested Features to Basins #20

Open
gzt5142 opened this issue Jan 5, 2023 · 0 comments
Open

Link Ingested Features to Basins #20

gzt5142 opened this issue Jan 5, 2023 · 0 comments
Assignees

Comments

@gzt5142
Copy link
Owner

gzt5142 commented Jan 5, 2023

From the original SQL definitions:

To link a point to its catchments:

<update id="linkPoint" >
update nldi_data.${tempTableName,jdbcType=VARCHAR} upd_table
	set comid = featureid
from nldi_data.${tempTableName,jdbcType=VARCHAR} src_table
	join nhdplus.catchmentsp
	on ST_covers(catchmentsp.the_geom, src_table.location)
	where upd_table.crawler_source_id = src_table.crawler_source_id and
		upd_table.identifier = src_table.identifier
</update>

To link a reach to its catchment:

<update id="linkReachMeasure">
update nldi_data.${tempTableName,jdbcType=VARCHAR} upd_table
	set comid = nhdflowline_np21.nhdplus_comid
from nldi_data.${tempTableName,jdbcType=VARCHAR} src_table
		  join nhdplus.nhdflowline_np21
		  on nhdflowline_np21.reachcode = src_table.reachcode and
		   src_table.measure between nhdflowline_np21.fmeasure and nhdflowline_np21.tmeasure
		  where upd_table.crawler_source_id = src_table.crawler_source_id and
		   upd_table.identifier = src_table.identifier
</update>

Need to implement this using SQL Alchemy in the python port.

It will be reasonably easy to just execute a 'raw' SQL statement such as the above using the SQLAlchemy mechanism -- but this opens up problems with injection, error-trapping, and also debugging. Need to 'translate' this into the appropriate API calls using the connection Engine().

@gzt5142 gzt5142 self-assigned this Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant