geoprep 0.1.5
Preprocessing for reaster/vector geospatial data
Requires Python: >=3.6

# GeoPrep

Read raster and vector geospatial data formats and preprocess it.

## Documentation
Still in development

## Quick Start
Install with PyPI:
```bash
$ pip install geoprep
```

Import session:
```python
>>> import geoprep as gp
```

You can read the geospatial data using filename:
```python
>>> rst = gp.read_raster('raster_sample.tif')
>>> vec = gp.read_vector('vector_sample.shp')
```

You can reproject your raster file:
```python
>>> rst_proj = rst.reprojection(epsg_to=3857)
```

Or polygonize:
```python
>>> poly = rst.polygonize()
```

Save to your path:
```python
>>> rst.to_tiff('raster_binarized.tif')
>>> poly.to_shape('raster_polygonized.shp')
```


## API reference
### Read
```python
>>> gp.Function(param1, param2, ...)
```
| Function                          | Description               | Output                |
| ---                               | ---                       | ---                   |
| read_raster(file_ref)             | Raster 파일 읽기          | Raster                |
| read_numpy(origin=[0,0], pixel_size=[0.02, 0.02], epsg=4283, NDV=-999)    | Numpy array 읽기      | Raster        |
| read_vector(file_ref)             | Vector 파일 읽기          | Vector                |

### Raster
```python
>>> rst.Function(param1, param2, ...)
```
| Function                                          | Description                   | Output                    |
| ---                                               | ---                           | ---                       |
| set_epsg(epsg, warning=True)                      | EPSG 좌표계 설정(변환 아님)    | -                        |
| reprojection(xRes=None, yRes=None, epsg_to=4283)  | 좌표계 변환                   | Raster                    |
| polygonize(band_num=1, mask=None)                 | Raster를 Shapefile로 변환     | Vector                    |
| boundary()                                        | 해당 경계값을 반환            | (xMin, yMax, xMax, yMin)  |
| clip_by_bound(xMin, yMax, xMax, yMin, include_boundary=False)             | 해당 좌표 경계로 clip         | Raster                    |
| clip_by_polygon(vector, NDV=None)                 | Polygon 모양으로 clip         | Raster                    |
| to_tiff(file_ref)                                 | 해당 경로에 tif로 저장        | -                         |
| to_numpy(band_num=1)                              | 해당 밴드를 numpy로 변환      | Numpy array               |
| binarize()                                        | 값이 있으면 1, 없으면 0       | Raster                    |
| thresholding(th_percentage=80)                    | threshold 넘으면 1, 아니면 0  | Raster                    |
| get_fault_density(radius=0.1)                     | Gausian filter                | Raster                    |
| get_fault_proximity(max_distance=10)              | 근접도 측정                   | Raster                    |

### Vector
```python
>>> vec.Function(param1, param2, ...)
```
| Function                                                  | Description                   | Output    |
| ---                                                       | ---                           | ---       |
| rasterize(x_res=0.02, y_res=0.02, attr=None, NDV=-999)    | Vector를 raster로 바꿈        | Raster    |
| get_field_names()                                         | Field 이름들을 반환           | List      |
| to_shape(file_ref)                                        | 해당 경로에 shp으로 저장      | -         |
| add_polygon(coords, field_values)                         | Polygon 추가                  | Vector    |
| add_line(coords, field_values)                            | Line 추가                     | Vector    |
| add_point(coord, field_values)                            | Point 추가                    | Vector    |
| is_valid()                                                | Validation check              | Boolean   |
| self_intersect_correction()                               | Self-intersect 고치기         | -         |
| intersect(overlay_vector)                                 | 겹치는 부분 출력              | Vector    |

### Merge
```python
>>> gp.Function(param1, param2, ...)
```
| Function                              | Description               | Output    |
| ---                                   | ---                       | ---       |
| merge_raster([raster1, raster2, ...]) | Raster들을 하나로 통합    | Raster    |
| intersect_vector(input_vector, overlay_vector) | Vector 겹치는 부분   | Vector    |

## Dependencies
- [Numpy](https://www.numpy.org)
- [Scipy](https://www.scipy.org)
- [GDAL](https://gdal.org)

### GDAL Installation
Installing with Anaconda:
```bash
$ conda install -c conda-forge gdal
```

Installing using Ubuntu Advanced Package Tool and PyPI:
```bash
$ sudo add-apt-repository ppa:ubuntugis/ppa
$ sudo apt-get update
$ sudo apt-get install gdal-bin
$ sudo apt-get install libgdal-dev
$ export CPLUS_INCLUDE_PATH=/usr/include/gdal
$ export C_INCLUDE_PATH=/usr/include/gdal
$ pip install GDAL
```